package com.vibration.baseinfo.service.impl;

import java.util.Calendar;
import java.util.List;

import com.vibration.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.vibration.baseinfo.mapper.CzTemperatureDataMapper;
import com.vibration.baseinfo.domain.CzTemperatureData;
import com.vibration.baseinfo.service.ICzTemperatureDataService;

/**
 * 探针任务Service业务层处理
 * 
 * @author Mr_Wu
 * @date 2022-11-07
 */
@Service
public class CzTemperatureDataServiceImpl implements ICzTemperatureDataService 
{
    @Autowired
    private CzTemperatureDataMapper czTemperatureDataMapper;

    /**
     * 查询探针任务
     * 
     * @param id 探针任务主键
     * @return 探针任务
     */
    @Override
    public CzTemperatureData selectCzTemperatureDataById(Long id)
    {
        return czTemperatureDataMapper.selectCzTemperatureDataById(id);
    }

    /**
     * 查询探针任务列表
     * 
     * @param czTemperatureData 探针任务
     * @return 探针任务
     */
    @Override
    public List<CzTemperatureData> selectCzTemperatureDataList(CzTemperatureData czTemperatureData)
    {
        return czTemperatureDataMapper.selectCzTemperatureDataList(czTemperatureData);
    }

    /**
     * 新增探针任务
     * 
     * @param czTemperatureData 探针任务
     * @return 结果
     */
    @Override
    public int insertCzTemperatureData(CzTemperatureData czTemperatureData)
    {
        return czTemperatureDataMapper.insertCzTemperatureData(czTemperatureData);
    }

    /**
     * 修改探针任务
     * 
     * @param czTemperatureData 探针任务
     * @return 结果
     */
    @Override
    public int updateCzTemperatureData(CzTemperatureData czTemperatureData)
    {
        return czTemperatureDataMapper.updateCzTemperatureData(czTemperatureData);
    }

    /**
     * 批量删除探针任务
     * 
     * @param ids 需要删除的探针任务主键
     * @return 结果
     */
    @Override
    public int deleteCzTemperatureDataByIds(Long[] ids)
    {
        return czTemperatureDataMapper.deleteCzTemperatureDataByIds(ids);
    }

    /**
     * 删除探针任务信息
     * 
     * @param id 探针任务主键
     * @return 结果
     */
    @Override
    public int deleteCzTemperatureDataById(Long id)
    {
        return czTemperatureDataMapper.deleteCzTemperatureDataById(id);
    }

    /**
     * 查询最近一小时温度数据
     * @param equipmentCode
     * @return
     */
    @Override
    public List<CzTemperatureData> selectCzTemperatureDataByCodeOneHour(String equipmentCode) {
        //一小时之前时间戳
        Calendar c = Calendar.getInstance();
        c.add(Calendar.HOUR_OF_DAY,-1);
        return czTemperatureDataMapper.selectCzTemperatureDataByCodeOneHour(equipmentCode,c.getTimeInMillis());
    }

    @Override
    public CzTemperatureData checkTempById(String id) {
        return czTemperatureDataMapper.checkTempById(id);
    }

    @Override
    public List<CzTemperatureData> findTempData(String id) {
        return czTemperatureDataMapper.findTempData(id);
    }

    @Override
    public int dataCountByTaskId(Long taskId) {
        return czTemperatureDataMapper.dataCountByTaskId(taskId);
    }
}
